/**
 * @name Find Symbol Definition
 * @kind problem
 * @problem.severity info
 * @description Finds the definition of a given symbol
 * @id cpp/find-definition
 */

import cpp

// 查找函数定义
from Function f
where f.getName().matches("%${symbolName}%")
  // 排除标准库
  and not f.getFile().getRelativePath().matches("%/usr/%")
select 
  f.getName() as name,
  f.getQualifiedName() as qualifiedName,
  f.getFile().getRelativePath() as filePath,
  f.getLocation().getStartLine() as line,
  f.getLocation().getStartColumn() as column,
  "Definition of " + f.getName() + " at " + f.getFile().getRelativePath() + ":" + f.getLocation().getStartLine()
limit 10

